<?php

class BaseController extends Controller {

    public function __construct() {
        if (Auth::check() && !CNamHoa::checkPermission(Route::currentRouteName(), ['isPost' => Request::isMethod('post')])) {
            $this->showPermissionError();
        }
    }

    protected function setupLayout() {
        if (!is_null($this->layout)) {
            $this->layout = View::make($this->layout);
        }
    }

    private function showPermissionError($code = 403, $message = "") {
        App::abort($code);
    }

}
